-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix compile of Go plugin or shared library for Linux ARM64 #129
Conversation
Add test to try to cross compile a Go plugin for Linux ARM64, requiring the command `$CC -fuse-ld=gold -Wl,--version`, executed by the Go toolchain, to return the string `GNU gold`. Using Go *1.20.4*: ``` link: ARM external linker must be gold (issue #15696), but is not: zig ld 0.11.0 ``` Using Go *1.21.3*: ``` link: ARM64 external linker must be gold (issue #15696, 22040), but is not: zig ld 0.11.0 ``` Building a Go `plugin` library force the Go toolchain to pass in the code [1] to link the binary. Enable CGO and cross compile (GOOS=linux GOARCH=arm64) is not sufficient. See https://go.dev/issue/15696 and https://go.dev/issue/22040 for more details. Issue: #122 [1]: https://go.googlesource.com/go/+/8c92897e15d15fbc664cd5a05132ce800cf4017f/src/cmd/link/internal/ld/lib.go#1628
Thank you for filing this.
This is the main culprit. In this case, go should also accept I will accept this particular PR as a temporary measure once there is a proper fix merged to Go. Then we can delete it after the next Go major version gets released. |
Yes, I totaly agree, the fix should be done in Go. I didn't know a PR in Go was in progress. |
Sorry, there is no PR in progress in Go. I meant Go is OK with zig-specific patches, and I suggested looking into my PRs for examples (almost all are zig specific IIRC). |
Cross compile a Go plugin for Linux ARM64 requires the command
$CC -fuse-ld=gold -Wl,--version
, executed by the Go toolchain, return the stringGNU gold
.Using Go 1.20.4:
Using Go 1.21.3:
Building a Go
plugin
library force the Go toolchain to pass in the code src/cmd/link/internal/ld/lib.go to link the binary.See https://go.dev/issue/15696 and https://go.dev/issue/22040 for more details.
Fixes #122